package com.market.remote.factory;

import com.market.cart.common.domain.CartInfo;
import com.market.common.core.domain.Result;
import com.market.remote.RemoteCartService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

public class RemoteCartServiceFallbackFactory implements FallbackFactory<RemoteCartService> {

    private static final Logger log= LoggerFactory.getLogger(RemoteCartServiceFallbackFactory.class);

    @Override
    public RemoteCartService create(Throwable cause) {
        log.error("购物车服务调用失败:{}" + cause.getMessage());
        return new RemoteCartService() {
            @Override
            public Result add(CartInfo cartInfo) {
                return Result.error("新增订单失败" + cause.getMessage());
            }
        };
    }

}
